local skel = fk.CreateSkill {
  name = "lb_zero__mengyao_mandela",
  max_branches_use_time = {
    ["round"] = {
      [Player.HistoryRound] = 1,
    }
  }
}

Fk:loadTranslationTable {
  ["lb_zero__mengyao_mandela"] = "曼德拉",
  --[":lb_zero__mengyao_mandela"] = "每回合限一次，出牌阶段或当你受到伤害后，你可以弃置两张牌，回复1点体力。",
  [":lb_zero__mengyao_mandela"] = "每轮限一次，当你受到伤害后，你可以弃置两张牌，然后回复1点体力。",

  ["#lb_zero__mengyao_mandela"] = "曼德拉：你可以弃置两张牌，回复1点体力",

  ["$lb_zero__mengyao_mandela1"] = "",
  ["$lb_zero__mengyao_mandela2"] = "",
}
--[[
skel:addEffect("active", {
  prompt = "#lb_zero__mengyao_mandela",
  can_use = function(self, player)
    return player:usedSkillTimes(skel.name) == 0
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected < 2 and not player:prohibitDiscard(to_select)
  end,
  target_filter = Util.FalseFunc,
  feasible = function(self, player, selected, selected_cards, card)
    return #selected_cards == 2
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local cards = effect.cards
    room:throwCard(cards, skel.name, player)
    if player.dead then return end
    room:recover {
      who = player,
      num = 1,
      skillName = skel.name,
      recoverBy = player,
    }
  end,
})
--]]
skel:addEffect(fk.Damaged, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and #player:getCardIds("he") > 1
        and player:usedSkillTimes(skel.name, Player.HistoryRound, "round") == 0
  end,
  on_cost = function(self, event, target, player, data)
    local cards = player.room:askToDiscard(player, {
      min_num = 2,
      max_num = 2,
      skill_name = skel.name,
      cancelable = true,
      skip = true,
      prompt = "#lb_zero__mengyao_mandela",
      include_equip = true,
    })
    if #cards > 1 then
      event:setCostData(self, { cards = cards })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player:addSkillBranchUseHistory(skel.name, "round")
    data.extra_data = data.extra_data or {}
    data.extra_data.lb_zero__huiyin = true
    local room = player.room
    local cards = event:getCostData(self).cards
    room:throwCard(cards, skel.name, player)
    if player.dead or not player:isWounded() then return end
    room:recover {
      who = player,
      num = 1,
      skillName = skel.name,
      recoverBy = player,
    }
  end
})

return skel
